#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->setWindowIcon(QIcon(":/icon/bulm.ico"));



    // 1.创建两个菜单 （文件） （设置）
    QMenu* fileMenu = new QMenu("文件(&F)", this);
    this->menuBar()->addMenu(fileMenu);

    QMenu* setMenu = new QMenu("设置(&S)", this);
    this->menuBar()->addMenu(setMenu);

    // 2.创建菜单项，并设置快捷键
    QAction* createProject = new QAction(QIcon(":/icon/createpro.png"), "创建项目", this);
    createProject->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_N));
    QAction* openProject = new QAction(QIcon(":/icon/openpro.png"), "保存项目", this);
    openProject->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_O));

    QAction* setMusic = new QAction(QIcon(":/icon/music.png"), "设置音乐", this);
    setMusic->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));

    // 3.添加到"文件"菜单和"设置"菜单中
    fileMenu->addAction(createProject);
    fileMenu->addAction(openProject);

    setMenu->addAction(setMusic);


    connect(createProject, &QAction::triggered, this, &MainWindow::handleCreatePro);
    connect(openProject, &QAction::triggered, this, &MainWindow::handleOpenPro);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::handleCreatePro(bool)
{
    qDebug() << "handleCreateSuccess";
}

void MainWindow::handleOpenPro(bool)
{

}

